package io.pesc.spring.context;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.context.support.GenericXmlApplicationContext;

public class Test {

    /**
     * 使用ApplicationContext创建spring bean容器
     * @param args
     */
    public static void main(String[] args) {
        // 使用 GenericXmlApplicationContext 创建spring bean容器
        ApplicationContext ac = new GenericXmlApplicationContext("io/pesc/spring/context/application.xml");
        Object person1 = ac.getBean("person");
        System.out.println(person1.toString());

        // 使用 ClassPathXmlApplicationContext 创建spring bean容器
        ac = new ClassPathXmlApplicationContext("io/pesc/spring/context/application.xml");
        Object person2 = ac.getBean("person");
        System.out.println(person2.toString());
    }
}
